package com.hm.web.servlet;


import com.fasterxml.jackson.databind.ObjectMapper;
import com.hm.pojo.ResponseData;
import com.hm.pojo.Result;
import com.hm.pojo.Student;

import com.hm.pojo.Teacher;
import com.hm.service.Impl.TeacherServiceImpl;
import com.hm.service.TeacherService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/teacher/*")
public class TeacherServlet {

    private TeacherService teacherService =  new TeacherServiceImpl();
    private ObjectMapper objectMapper = new ObjectMapper();
    public void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //老师登录
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        System.out.println(username+password);
        Teacher login = teacherService.login("2020010101", "123456");
        Result<Teacher> success = ResponseData.success(login);
        String s = objectMapper.writeValueAsString(success);
        resp.getWriter().write(s);
    }

}
